//
//  ListItemCellTableViewCell.swift
//  feiyu444
//
//  Created by hanweiguang on 2018/10/15.
//  Copyright © 2018年 hanweiguang. All rights reserved.
//

import UIKit
import SnapKit
// 进行自定义item
class ListItemCell: UITableViewCell {
    
    var formView: UIView!
    var topView: UIView!
    var titleLabel: UILabel! //用户昵称
    var titleLabel2: UILabel! //地址
    
    
    var userMobile: UILabel! //手机号
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.setUpUI()
    }
    
    func setUpUI() {
        formView=UIView()
        formView.backgroundColor=UIColor.color(hexString: "#f9f9f9")
        formView.layer.cornerRadius = 6.0
        formView.layer.borderColor =  UIColor.color(hexString: "#d9d9d9").cgColor
        formView.layer.borderWidth = 0.5
        
        
        
        topView=UIView()
        topView.backgroundColor=UIColor.color(hexString: "#fc5b56")
        topView.layer.cornerRadius = 6.0
        topView.layer.maskedCorners = [CACornerMask.layerMinXMinYCorner , CACornerMask.layerMaxXMinYCorner,CACornerMask.layerMaxXMaxYCorner]
        topView.layer.masksToBounds = true
        topView.layer.borderWidth = 0.5
        topView.layer.borderColor =  UIColor.white.cgColor
        
        formView.addSubview(topView)
        topView.snp.makeConstraints{
            (make) in
            make.left.equalToSuperview()
            make.right.equalToSuperview()
            make.height.equalTo(40)
            make.width.equalTo(kScreenWidth-15)
        }
        
        
        
        titleLabel = UILabel()
        titleLabel.textAlignment = .left;
        titleLabel.textColor = UIColor.color(hexString: "#323232");
        titleLabel.font = UIFont.systemFont(ofSize: 15);
        titleLabel.text = "韩伟光"
        // 添加布局
        formView.addSubview(titleLabel)
        
        //设置位置
        titleLabel.snp.makeConstraints{
            (make) in
            make.topMargin.equalTo(40)
            make.left.equalToSuperview()
            make.right.equalToSuperview()
            make.height.equalTo(frame.size.height)
            make.width.equalTo(frame.size.width)
        }
        
        
        titleLabel2 = UILabel()
        titleLabel2.textColor = UIColor.color(hexString: "#323232");
        titleLabel2.font = UIFont.systemFont(ofSize: 15);
        titleLabel2.text = "安徽省合肥市蜀山区井冈镇"
        // 添加布局
        formView.addSubview(titleLabel2)
        //设置位置
        titleLabel2.snp.makeConstraints{
            (make) in
            
            make.topMargin.equalTo(60)
            make.left.equalToSuperview()
            make.right.equalToSuperview()
            
            make.height.equalTo(frame.size.height)
            make.width.equalTo(frame.size.width)
        }
        
        
        userMobile=UILabel()
        userMobile.textColor = UIColor.color(hexString: "#323232");
        userMobile.backgroundColor=UIColor.color(hexString: "#ff1122")
        userMobile.font = UIFont.systemFont(ofSize: 15);
        userMobile.text="13155186288"
        userMobile.textAlignment = .right
        formView.addSubview(userMobile)
        userMobile.snp.makeConstraints{
            (make) in
            
            make.right.equalTo(formView.snp.right)
            make.topMargin.equalTo(40)
            make.height.equalTo(frame.size.height)
            make.width.equalTo(frame.size.width/2)
        }
        contentView.addSubview(formView)
        
        formView.snp.makeConstraints{
            (make) in
            
            make.height.equalTo(115)
            make.center.equalToSuperview()
            make.width.equalTo(kScreenWidth-15)
        }
        
        
        
        //https://blog.fe.ioteams.com/post/swiftSnapKitBaseUse.html#toc-16c
        
    }
    
    func setValueForCell(dic: NSDictionary) {
        
        
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
    }
    
    
}
